import java.util.Arrays;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime 2023/2/2 9:29 PM
 * @company Michale Squirrel
 * @link
 * @description
 */
public class Node {

    int id = -1;

    int[] nextNodes = null; // 如果没有下游相邻节点，则为空序列[]



    static Node parseInfo(String str) {

        Node node = new Node();

        String[] temp = str.split(":\\s?");

        node.id = Integer.parseInt(temp[0]);

        if (temp.length > 1 && temp[1].length() > 0) {

            node.nextNodes = Arrays.stream(temp[1].split("\\s+"))

                    .mapToInt(Integer::parseInt).toArray();

        } else {

            node.nextNodes = new int[]{};

        }

        return node;

    }

    public String toString() {

        return this.id + " : " + Arrays.toString(this.nextNodes);

    }
}
